﻿using ThingyCloud.Creatures;

namespace ThingyCloud.Network.Messages
{
	class ThingyMoveMessage : Message
	{
		/// <summary>
		/// The thingy that is considered in this message
		/// </summary>
		private Thingy thingy;

		/// <summary>
		/// Rotation in degrees
		/// </summary>
		private int r;

		/// <summary>
		/// Position
		/// </summary>
		private double x, y;
		
		/// <summary>
		/// Creates a new message, and we need the thingy for that
		/// </summary>
		public ThingyMoveMessage(Thingy thingy, double x, double y, int r)
		{
			this.thingy = thingy;
			this.x = x;
			this.y = y;
			this.r = r;
		}

		/// <summary>
		/// Builds the message string required by the end point
		/// </summary>
		/// <returns></returns>
		public override string ToMessageString()
		{
			return string.Format(
					"action:move;id:{0};crid:{1};var:{2};x:{3};y:{4};r:{5};",
					thingy.ID,
					thingy.Properties.ID,
					thingy.Variant.ID,
					Globals.ToAbsX(x),
					Globals.ToAbsY(y),
					r
					);
		}
	}
}
